/*   1:    */ package org.intellij.images.thumbnail.impl;
/*   2:    */ 
/*   3:    */

import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowAnchor;
import com.intellij.openapi.wm.ToolWindowManager;
import icons.ImagesIcons;
import org.intellij.images.thumbnail.ThumbnailView;
import org.intellij.images.vfs.IfsUtil;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */ 
/*  14:    */ final class ThumbnailViewImpl
/*  15:    */   implements ThumbnailView
/*  16:    */ {
/*  17:    */   private final Project a;
/*  18:    */   private final ToolWindow b;
/*  19: 44 */   private boolean c = false;
/*  20: 45 */   private VirtualFile d = null;
/*  21:    */   private final ThumbnailViewUI e;
/*  22:    */   
/*  23:    */   public ThumbnailViewImpl(Project paramProject)
/*  24:    */   {
/*  25: 49 */     this.a = paramProject;
/*  26:    */     
/*  27: 51 */     ToolWindowManager localToolWindowManager = ToolWindowManager.getInstance(paramProject);
/*  28: 52 */     this.e = new ThumbnailViewUI(this);
/*  29: 53 */     this.b = localToolWindowManager.registerToolWindow(TOOLWINDOW_ID, this.e, ToolWindowAnchor.BOTTOM);
/*  30: 54 */     this.b.setIcon(ImagesIcons.ThumbnailToolWindow);
/*  31: 55 */     setVisible(false);
/*  32:    */   }
/*  33:    */   
/*  34:    */   private ThumbnailViewUI a()
/*  35:    */   {
/*  36: 59 */     return this.e;
/*  37:    */   }
/*  38:    */   
/*  39:    */   public void setRoot(@NotNull VirtualFile paramVirtualFile)
/*  40:    */   {
/*  41: 63 */     if (paramVirtualFile == null) {
/*  42: 63 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/images/thumbnail/impl/ThumbnailViewImpl", "setRoot" }));
/*  43:    */     }
/*  44: 63 */     this.d = paramVirtualFile;
/*  45: 64 */     b();
/*  46:    */   }
/*  47:    */   
/*  48:    */   public VirtualFile getRoot()
/*  49:    */   {
/*  50: 68 */     return this.d;
/*  51:    */   }
/*  52:    */   
/*  53:    */   public boolean isRecursive()
/*  54:    */   {
/*  55: 72 */     return this.c;
/*  56:    */   }
/*  57:    */   
/*  58:    */   public void setRecursive(boolean paramBoolean)
/*  59:    */   {
/*  60: 76 */     this.c = paramBoolean;
/*  61: 77 */     b();
/*  62:    */   }
/*  63:    */   
/*  64:    */   public void setSelected(@NotNull VirtualFile paramVirtualFile, boolean paramBoolean)
/*  65:    */   {
/*  66: 81 */     if (paramVirtualFile == null) {
/*  67: 81 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/images/thumbnail/impl/ThumbnailViewImpl", "setSelected" }));
/*  68:    */     }
/*  69: 81 */     if (isVisible()) {
/*  70: 82 */       a().setSelected(paramVirtualFile, paramBoolean);
/*  71:    */     }
/*  72:    */   }
/*  73:    */   
/*  74:    */   public boolean isSelected(@NotNull VirtualFile paramVirtualFile)
/*  75:    */   {
/*  76: 87 */     if (paramVirtualFile == null) {
/*  77: 87 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/images/thumbnail/impl/ThumbnailViewImpl", "isSelected" }));
/*  78:    */     }
/*  79: 87 */     return (isVisible()) && (a().isSelected(paramVirtualFile));
/*  80:    */   }
/*  81:    */   
/*  82:    */   @NotNull
/*  83:    */   public VirtualFile[] getSelection()
/*  84:    */   {
/*  85: 92 */     if (isVisible())
/*  86:    */     {
/*  87: 93 */       VirtualFile[] tmp14_11 = a().getSelection();
/*  88: 93 */       if (tmp14_11 == null) {
/*  89: 93 */         throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/images/thumbnail/impl/ThumbnailViewImpl", "getSelection" }));
/*  90:    */       }
/*  91: 93 */       return tmp14_11;
/*  92:    */     }
/*  93: 95 */     VirtualFile[] tmp52_49 = VirtualFile.EMPTY_ARRAY;
/*  94: 95 */     if (tmp52_49 == null) {
/*  95: 95 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/images/thumbnail/impl/ThumbnailViewImpl", "getSelection" }));
/*  96:    */     }
/*  97: 95 */     return tmp52_49;
/*  98:    */   }
/*  99:    */   
/* 100:    */   public void scrollToSelection()
/* 101:    */   {
/* 102: 99 */     if (isVisible()) {
/* 103:100 */       if (!this.b.isActive()) {
/* 104:101 */         this.b.activate(new LazyScroller(null));
/* 105:    */       } else {
/* 106:104 */         a().scrollToSelection();
/* 107:    */       }
/* 108:    */     }
/* 109:    */   }
/* 110:    */   
/* 111:    */   public boolean isVisible()
/* 112:    */   {
/* 113:110 */     return this.b.isAvailable();
/* 114:    */   }
/* 115:    */   
/* 116:    */   public void activate()
/* 117:    */   {
/* 118:114 */     if ((isVisible()) && (!this.b.isActive())) {
/* 119:115 */       this.b.activate(null);
/* 120:    */     }
/* 121:    */   }
/* 122:    */   
/* 123:    */   public void setVisible(boolean paramBoolean)
/* 124:    */   {
/* 125:120 */     this.b.setAvailable(paramBoolean, null);
/* 126:121 */     if (paramBoolean)
/* 127:    */     {
/* 128:122 */       c();
/* 129:123 */       a().refresh();
/* 130:    */     }
/* 131:    */     else
/* 132:    */     {
/* 133:126 */       a().dispose();
/* 134:    */     }
/* 135:    */   }
/* 136:    */   
/* 137:    */   private void b()
/* 138:    */   {
/* 139:131 */     if (isVisible())
/* 140:    */     {
/* 141:132 */       c();
/* 142:133 */       a().refresh();
/* 143:    */     }
/* 144:    */   }
/* 145:    */   
/* 146:    */   private void c()
/* 147:    */   {
/* 148:138 */     this.b.setTitle(this.d != null ? IfsUtil.getReferencePath(this.a, this.d) : null);
/* 149:    */   }
/* 150:    */   
/* 151:    */   @NotNull
/* 152:    */   public Project getProject()
/* 153:    */   {
/* 154:143 */     Project tmp4_1 = this.a;
/* 155:143 */     if (tmp4_1 == null) {
/* 156:143 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/images/thumbnail/impl/ThumbnailViewImpl", "getProject" }));
/* 157:    */     }
/* 158:143 */     return tmp4_1;
/* 159:    */   }
/* 160:    */   
/* 161:    */   public void setTransparencyChessboardVisible(boolean paramBoolean)
/* 162:    */   {
/* 163:147 */     if (isVisible()) {
/* 164:148 */       a().setTransparencyChessboardVisible(paramBoolean);
/* 165:    */     }
/* 166:    */   }
/* 167:    */   
/* 168:    */   public boolean isTransparencyChessboardVisible()
/* 169:    */   {
/* 170:153 */     return (isVisible()) && (a().isTransparencyChessboardVisible());
/* 171:    */   }
/* 172:    */   
/* 173:    */   public boolean isEnabledForActionPlace(String paramString)
/* 174:    */   {
/* 175:158 */     return (isVisible()) && (!"Images.Editor".equals(paramString));
/* 176:    */   }
/* 177:    */   
/* 178:    */   public void dispose()
/* 179:    */   {
/* 180:163 */     a().dispose();
/* 181:    */     
/* 182:165 */     ToolWindowManager localToolWindowManager = ToolWindowManager.getInstance(this.a);
/* 183:166 */     localToolWindowManager.unregisterToolWindow(TOOLWINDOW_ID);
/* 184:    */   }
/* 185:    */   
/* 186:    */   private final class LazyScroller
/* 187:    */     implements Runnable
/* 188:    */   {
/* 189:    */     private LazyScroller() {}
/* 190:    */     
/* 191:    */     public void run()
/* 192:    */     {
/* 193:171 */       SwingUtilities.invokeLater(new Runnable()
/* 194:    */       {
/* 195:    */         public void run()
/* 196:    */         {
/* 197:173 */           ThumbnailViewImpl.this.a().scrollToSelection();
/* 198:    */         }
/* 199:    */       });
/* 200:    */     }
/* 201:    */   }
/* 202:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.images.thumbnail.impl.ThumbnailViewImpl

 * JD-Core Version:    0.7.0.1

 */